package chap4_4对象序列化流;

import java.io.Serializable;

/**
 * @author https://gitee.com/W_Jun
 * @date 2021-12-17 13:41
 * @Description 要序列化的对象的类Student
 */
public class Student implements Serializable {
    //InvalidClassException异常的解决办法就是显式声明serialVersionUID
    //private static final long serialVersionUID = 42L;
    private String name;
    //如果age属性不想被序列化，需要使用transient关键字修饰
    //private int age;
    private transient int age;

    public Student(){}

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

/*    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }*/
}
